home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Jun 89 / V0019-Re TStdPrintHandler-Jun89 < prev    next >
Encoding:
Text File  |  1989-06-26  |  3.1 KB  |  81 lines  |  [TEXT/GEOL]

  1. Item    9763868                         6-June-89        22:46
  2.  
  3. From:   CREMER.M                        Cremer, Mike
  4.  
  5. To:     UK0034                          Baum, Peter, Uk Dev London
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    Re: TStdPrintHandler query
  10.  
  11. Peter,
  12.  
  13. For each and every printable view, the view should also have a printhandler
  14. object.  For views that do not print, no printhandler should be created.
  15.  
  16. Given: (a) all separate view are in separate windows; (b) you are taking
  17. default page setup options for margins, etc.
  18.  
  19. Consider:  Suppose I have two views, TPrintMeView and TDontPrintMeView, both of
  20. which I display on the screen.  When I create each view, my method will look
  21. something like:
  22.  
  23. { Create a TPrintMeView }
  24.  
  25.    IF (forPrinting)
  26.      THEN { we're printing directly, so no need for a window object }
  27.     printMeView := TPrintMeView(DoCreateViews(SELF, NIL, kPrintMeView))
  28.    ELSE { we're creating a screen view, so make the window }
  29.     BEGIN
  30.          aWindow := NewTemplateWindow(kPrintMeWindow, SELF);
  31.        printMeView := TPrintMeView(aWindow.FindSubView('VW01'));
  32.        END;
  33.  
  34. { next step is used only when creating a printable view }
  35.  
  36.    New(aPrintHandler);  FailNIL(aPrintHandler);
  37.    aPrintHandler.IStdPrintHandler(SELF,           { its document    }
  38.                                printMeView,    { its view   }
  39.                                FALSE,            { does not have square dots
  40.                                TRUE,           { horzontal page size is fixed
  41.                                   TRUE);             { vertical page size is fi
  42.  
  43. { Create a TDontPrintMeView }
  44.  
  45. IF (forPrinting)
  46.   THEN { nothing, since we can't print a TDontPrintMeView }
  47.   ELSE
  48.     BEGIN
  49.       anotherWindow := NewTemplateWindow(kDontPrintMeWindow, SELF);
  50.       dontPrintMeView := TPrintMeView(anotherWindow.FindSUbView('VW02'));
  51.       dontPrinMeView.fPrintHandler := NIL;
  52.     END;
  53.  
  54. { end of codeFrag }
  55.  
  56. Note that this is normally done in a TDocument.DoMakeViews.  If you are
  57. creating these views in TApplication, then the SELF parameters should be NIL.
  58.  
  59. From here on out, let MacApp worry about which menus to enable or disable.
  60. MacApp will check to see if a print handler is installed and let the print
  61. handler enable the menu items it can handle  (the default TView.DoSetupmenus
  62. calls fPrintHandler.DoSetupMenus).  If you haven't installed a print handler,
  63. the Print… etc. menus will not be enabled.
  64.  
  65. As far as printing the correct view when Print… is selected, MacApp uses the
  66. target view's printhandler (if it exists), to handle the command.
  67. Specifically, TView.DoMenuCommand will trap Print… commands and direct them to
  68. its printhandler (if installed).  What is probably happening is that the
  69. non-printable views are passing the Print… commands on to the next EvtHandler
  70. because they have no printhandler to process the menu command, and the next
  71. Evthandler in the chain happens to be a printable view.  The simplest solution
  72. is to override TView.DoMenuCommand in the non-printable views, trap all the
  73. Print… commands, and do nothing with them (look in TView.DoMenuCommand to see
  74. what I mean).
  75.  
  76. Hope this helps.
  77.  
  78. $mike cremer
  79. Apple Computer, Inc.
  80.  
  81.